/**
 * @param {number[]} nums
 * @return {number}
 */
var getMaxLen = function (nums) {
  let res = 0
  let left = 0, right, mul
  while (left < nums.length) {
    mul = 1
    for (right = left; right < nums.length; right++) {
      mul *= nums[right]
      if (mul > 0) res = Math.max(res, right - left + 1)
    }
    left++
  }

  return res
};

getMaxLen([1, -2, -3, 4])